package TreeMap;

import java.util.TreeMap;
import java.util.function.BiConsumer;

public class Test4 {
    public static void main(String[] args) {
        String str="aababcabcdabcde";
        TreeMap<Character,Integer> tm=new TreeMap<>();
        for (int i = 0; i < str.length(); i++) {
            char c = str.charAt(i);
            if(tm.containsKey(c)){
                Integer count = tm.get(c);
                count++;
                tm.put(c,count);
            }
            else{
                tm.put(c,1);
            }
        }
        StringBuilder sb=new StringBuilder();
        tm.forEach(( character,  integer) ->
                sb.append(character).append("(").append(integer).append(")")
        );
        System.out.println(sb);
    }
}
